function [ SigOut ] = OCDMdemod( SigIn, NDFNT )
%   fresnel transform反变换，用于OCDM调制(类似OFDM的fft调制矩阵)


NumberSymbol = size(SigIn, 2); %列数，信息符号数

if nargin == 1
    N = 2;
    while N < size(SigIn, 1)
        N = N * 2;
    end
    NDFNT = N;
elseif nargin == 2
    N = ceil(size(SigIn, 1)/NDFNT) * NDFNT; 
end
L = N - size(SigIn, 1);
SigIn = [SigIn; zeros(L, NumberSymbol)]; %补零

Phi_1 = zeros(NDFNT, NDFNT);
Phi_2 = zeros(NDFNT, NDFNT);
for m = 0 : NDFNT-1
    Phi_1(m+1, m+1) = exp(-1i* pi/4)*exp(1i*(pi/NDFNT)*m^2);
    Phi_2(m+1, m+1) = exp(1i*(pi/NDFNT)*m^2);
end

SigOut = zeros(size(SigIn));
for m = 1 : NumberSymbol
    for n = 1 : ceil(size(SigIn, 1)/ NDFNT)
        SigOut((n-1)*NDFNT + 1 : n*NDFNT, m) = Phi_1 * SigIn((n-1)*NDFNT + 1 : n*NDFNT, m);
        SigOut((n-1)*NDFNT + 1 : n*NDFNT, m) = fft(SigOut((n-1)*NDFNT + 1 : n*NDFNT, m), NDFNT) ./ sqrt(NDFNT);
        SigOut((n-1)*NDFNT + 1 : n*NDFNT, m) = Phi_2 * SigOut((n-1)*NDFNT + 1 : n*NDFNT, m);
    end
end
end

